package com.ymatou.iapi.userservice.service;

import java.util.ArrayList;

import org.json.JSONObject;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.ymatou.iapi.userservice.parameter.resp.UserInfo;
import com.ymatou.iapi.userservice.parameter.resp.UserInfo2;
import com.ymt.base.YmatouBaseCall;
import com.ymttest.database.model.Userinfoex;
import com.ymttest.utils.EnvSetup;

/**
 * 根据userid批量查询用户信息明细Call FreeMaker Template自动生成代码
 */
public class BatchUserRequestDtoCall extends YmatouBaseCall {
	private static String opurl = "json/reply/BatchUserRequestDto";

	public BatchUserRequestDtoCall() {
		super(EnvSetup.getSystemUrl("userservice_iapi"), opurl, "POST", "JSON");
	}

	@Override
	public void addDefHeader() {
		client.addHeader("Accept", "text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}

	/**
	 * 获取Result
	 * 
	 * @return
	 */
	public ArrayList<UserInfo2> getResult() {
		ArrayList<UserInfo2> Result = new ArrayList<UserInfo2>();
		try {
			String result = new JSONObject(getReturnData()).optString("Result");
			Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss").disableHtmlEscaping().create();
			Result = (ArrayList<UserInfo2>) gson.fromJson(result, new TypeToken<ArrayList<UserInfo2>>() {
			}.getType());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Result;
	}

	/**
	 * 获取Result
	 * 
	 * @return
	 */
	public ArrayList<Userinfoex> getResultex() {
		ArrayList<Userinfoex> Result = new ArrayList<Userinfoex>();
		try {
			String result = new JSONObject(getReturnData()).getString("Result");
			Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss").disableHtmlEscaping().create();
			Result = (ArrayList<Userinfoex>) gson.fromJson(result, new TypeToken<ArrayList<Userinfoex>>() {
			}.getType());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Result;
	}
}